package org.brain.bean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.brain.dbo.DBOperate;
import org.brain.pojos.Treemenu;
import org.brain.pojos.User;
import org.brain.tool.ToolBean;

import antlr.build.Tool;

@ManagedBean(name="fatherNode")
@SessionScoped
public class FatherNodeMenu {
	List<Treemenu> fatherTree = new ArrayList<Treemenu>();
	String id; //docuemnt id
	String idReserve; //
	int row;
	User user;
	/*
	 * get id from URI
	 * */
	
	/*
	 * init document list from database
	 * 
	 * */
	
	public void initList()
	{
		user = ToolBean.getUserSession();
		//id = ToolBean.getRequestParameter("id"); 
		//当点击导航按钮时，会发送一个请求。默认是不带id参数的。这个我们为它，记录一个参数 
//		if(id!=null)
//			idReserve = id;
//		else
//			id = idReserve;
		fatherTree.clear();
		fatherTree = DBOperate.getTreeMenu(user.getUsername(), 0);
		//fatherTree = DBOperate.search("Document where nodeid="+id);
		row=fatherTree.size();
		System.out.println("documentid "+id);
		
	}
	
	
	public List<Treemenu> getFatherTree() {
		initList();
		return fatherTree;
	}


	public void setFatherTree(List<Treemenu> fatherTree) {
		this.fatherTree = fatherTree;
	}


	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
}
